/*
${' '}* Copyright ${.now?string('yyyy')} The JA-SIG Collaborative. All rights reserved.
${' '}* distributed with this file and available online at
${' '}*/
package ${basePackage}.adapter.driving.query.${module}.repository;

import ${basePackage}.adapter.driving.query.${module}.${className}QueryConverter;
import ${basePackage}.adapter.driving.query.${module}.po.${className}QueryPo;
import ${basePackage}.application.${module}.query.Query${className}PageQuery;
import ${basePackage}.application.${module}.query.${className}Dto;
import ${basePackage}.application.${module}.repository.${className}QueryRepository;
import ${basePackage}.adapter.driving.query.${module}.mapper.${className}QueryMapper;
import com.lap.framework.dto.page.PageResponse;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

@RequiredArgsConstructor
@Repository
public class ${className}QueryRepositoryImpl implements ${className}QueryRepository {

  private final ${className}QueryConverter converter;
  private final ${className}QueryMapper ${lowerName}QueryMapper;

  @Override
  public PageResponse<${className}Dto> findByConditionPaged(Query${className}PageQuery query) {
    long count = ${lowerName}QueryMapper.countPageByCondition(query);
    if (count == 0L) {
      return PageResponse.ok(count);
    }
    List<${className}QueryPo> list = ${lowerName}QueryMapper.selectPageByCondition(query);
    return PageResponse.ok(converter.toDtoList(list), count);
  }
}
